package MyGO;

import MyGO.Data.GlobalData;
import MyGO.Form.TrackForm;
import MyGO.entity.Doctor;
import MyGO.property.CheckPro;
import MyGO.service.ICheackProService;
import MyGO.service.IDoctorService;
import MyGO.service.IMedicineService;
import MyGO.service.ITrackFormService;
import MyGO.service.impl.CheckProServiceImpl;
import MyGO.service.impl.DoctorServiceImpl;
import MyGO.service.impl.MedicineServiceImpl;
import MyGO.service.impl.TrackFormServiceImpl;
import MyGO.utils.FileUtils.FileIO;
import com.fasterxml.jackson.core.type.TypeReference;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;

public class Main extends Application{

    public static void main(String[] args) throws IOException {
        TrackForm.count = FileIO.readObjectFromJsonFile("count.json", new TypeReference<Integer>() {});
//        Load.load();
        launch();
//        IDoctorService doctorService = new DoctorServiceImpl();
//        for (Doctor doctor : doctorService.selevtAllDoctor()) {
//            doctor.setInitAmount(10);
//        }
//        IMedicineService medicineService = new MedicineServiceImpl();
//        medicineService.getMedicineList().remove(medicineService.getMedicineList().size() - 1);


//        Delete.delete();
        Print.printTrackForm();

        // 注册钩子
        Runtime.getRuntime().addShutdownHook(new ShutdownHook());
        // 模拟程序运行
        System.out.println("Program is running. Press Ctrl+C to exit.");
        try {
            Thread.sleep(10000);  // 等待 10 秒
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // 正常退出
        System.out.println("Program is exiting.");
    }

    @Override
    public void start(Stage stage) throws Exception {
        GlobalData.stage = stage;
        FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/MyGO/fxml/login.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        stage.setTitle("东软云医院HIS系统");
        stage.setScene(scene);
        stage.show();
    }

}
